using System;
using System.Collections.Generic;
using System.Text;

namespace CLELCore.Assembly
{
	public class StreamHeader
	{
		public const int STRINGS_NAME_SIZE = 12;
		public const int US_NAME_SIZE = 4;
		public const int BLOB_NAME_SIZE = 8;
		public const int GUID_NAME_SIZE = 8;
		public const int TILDA_NAME_SIZE = 4;

		public const String STRINGS_NAME = "#Strings\0\0\0\0";
		public const String US_NAME = "#US\0";
		public const String BLOB_NAME = "#Blob\0\0\0";
		public const String GUID_NAME = "#GUID\0\0\0";
		public const String TILDA_NAME = "#~\0\0";

		private int _offset;
		private int _size;
		private byte[] _name;
		private String _nameasstring;

		public int Offset
		{
			get
			{
				return _offset;
			}
			set
			{
				_offset = value;
			}
		}
		public int Size
		{
			get
			{
				return _size;
			}
			set
			{
				_size = value;
			}
		}
		public String NameAsString
		{
			get
			{
				return _nameasstring;
			}
		}
		public byte[] Name
		{
			get
			{
				return _name;
			}
			set
			{
				if(value != null)
				{
					_name = value;
					_nameasstring = ASCIIEncoding.ASCII.GetString(value);
				}
			}
		}

		public StreamHeader()
		{
		}

		public StreamHeader(int offset,int size,byte[] name)
		{
			if(name == null)
				throw new Exception("Error - Stream Header name cannot be null");
			_offset = offset;
			_size = size;
			_name = name;
			_nameasstring = ASCIIEncoding.ASCII.GetString(name);
		}
	}
}
